﻿using System;
using System.Drawing;


public partial class UserControls_ColorPicker : System.Web.UI.UserControl
{
    public Color SelectedColor
    {
        get 
        {
            return this.uxColorPicker.SelectedColor;
        }
        set 
        {            
            this.uxColorPicker.SelectedColor = value;
            this.uxSelectedColor.InnerHtml = ColorTranslator.ToHtml(value);
        }
    }
    protected void Page_Load(object sender, EventArgs e)
    {

    }
    protected override void OnPreRender(EventArgs e)
    {
        base.OnPreRender(e);
        this.uxSelectedColor.InnerHtml = ColorTranslator.ToHtml(this.SelectedColor);
        string clientScript=@"function uxColorPicker_UpdateSelectedColor(sender, args) {
            var labelID = sender.get_id().replace('uxColorPicker', 'uxSelectedColor');
            var uxLabel = document.getElementById(labelID);
            uxLabel.innerHTML = sender.get_selectedColor();
        }";
        // If exists --> do not regist
        this.Page.ClientScript.RegisterClientScriptBlock(this.GetType(), "uxColorPicker_UpdateSelectedColor", clientScript, true);
    }   
   
}
